package org.jet.emall.security.handler;

import com.alibaba.fastjson.JSON;
import org.jet.emall.common.restful.result.CommonResult;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 注销成功回调
 * @author xiaozai
 * @version 1.0
 * @date 2020-04-12 15:00
 */

public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {


    @Override
    public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
        CommonResult<Object> result = CommonResult.success("注销成功");
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSON.toJSONString(result));
        response.flushBuffer();
    }
}
